package com.toprs.base.controller

import com.toprs.base.entity.Log
import com.toprs.base.query.LogQuery
import com.toprs.base.result.PageResult
import com.toprs.base.service.LogService
import org.springframework.web.bind.annotation.PostMapping
import org.springframework.web.bind.annotation.RequestBody
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RestController
import com.toprs.base.result.Result
import io.swagger.v3.oas.annotations.Operation
import io.swagger.v3.oas.annotations.tags.Tag

@RestController
@RequestMapping("/log")
@Tag(name = "日志管理")
class LogController(val logService: LogService) {


    @PostMapping("/query")
    @Operation(summary = "查询日志")
    fun queryLog(@RequestBody logQuery: LogQuery): Result<PageResult<Log>> {
        val res: PageResult<Log> = logService.queryLog(logQuery)
        return Result.success(res)
    }

    @PostMapping("/delete")
    fun deleteLogs(@RequestBody logIds: List<Int>): Result<Unit> {
        logService.deleteLogs(logIds)
        return Result.successMsg("删除成功")
    }

    @PostMapping("/exportExcel")
    @Operation(summary = "导出日志")
    fun exportExcel(@RequestBody logQuery: LogQuery): Result<String> {
        val res: String = logService.exportExcel(logQuery)
        return Result.success(res)
    }


}